<%--
  Created by IntelliJ IDEA.
  User: 兰宦君
  Date: 2015/10/9
  Time: 8:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html>
<head>
  <title>后台管理系统——职工管理</title>
  <%@ include file="../../layout/import.jsp"%>

  <script type="text/javascript">
    function submit() {
      $.ajax({
        url: "/admin/employeeSave.do",
        data: $('#employeeForm').serialize(),
        method: "POST",
        dataType: "json",
        error: function () {
          alert("表单提交出错，请稍后再试");
        },
        success: function(response) {
          if(response.code == 0) {
            alert("修改成功");
            window.location.href = "/admin/employee.do";

          }
          else {
            alert(response.description);
          }
        }
      });
    }
  </script>

</head>
<body>
<%@ include file="nav.jsp"%>

<div class="container" style="min-height: 72%">
  <div class="col-sm-8 col-sm-offset-2">

    <form class="form" id="employeeForm">
      <div class="form-group">
        <input type="hidden" name="employeeId" value="${employee.id}">
      </div>
      <div class="form-group">
        <label for="username">职工名</label>
        <input type="text" class="form-control" id="username" name="username" value="${employee.username}">
      </div>
      <div class="form-group">
        <label for="password">密码</label>
        <input type="password" class="form-control" id="password" name="password">
      </div>
      <div class="form-group">
        <label for="gender">性别</label>
        <select class="form-control" id="gender" name="gender">
          <option value="男" <c:if test="${employee.gender eq 男}">selected="selected" </c:if>>男</option>
          <option value="女" <c:if test="${employee.gender eq 女}">selected="selected" </c:if>>女</option>
        </select>
      </div>
      <div class="form-group">
        <label for="email">邮箱</label>
        <input type="email" class="form-control" id="email" name="email" value="${employee.email}">
      </div>

      <div class="form-group">
        <label for="phone">联系电话</label>
        <input type="number" class="form-control" id="phone" name="phone"value="${employee.phone}">
      </div>
      <div class="form-group">
        <label for="role">职务</label>
        <select class="form-control" id="role" name="role">
          <option value="0" <c:if test="${employee.role == '0'}">selected="selected" </c:if>>系统管理员</option>
          <option value="1" <c:if test="${employee.role == '1'}">selected="selected" </c:if>>图书管理员</option>
        </select>
      </div>
      <a class="btn btn-primary" onclick="submit()">提交</a>

    </form>

  </div>
</div>


<%@ include file="../footer.jsp"%>
</body>
</html>
